using System;

namespace EPPlayer
{
    /// <summary>
    /// All gear (Armor, ArmorMods, Enhancements, Cyberware) is jammed into once class
    /// for simplicity. 
    /// </summary>
    public class Gear : AttachableAttribute
    {
        public readonly Int32 KineticArmor, EnergyArmor;
        public string Cost, Type;
        public const string AttributeColor = "Gear";

        internal Gear(
            string Name,
            string Type,
            string Cost,
            Int32 KineticArmor, 
            Int32 EnergyArmor,
            Modifiers Modifiers, 
            string Description = null)
            : base(Name, AttributeColor, Modifiers, Description)
        {
            this.KineticArmor = KineticArmor;
            this.EnergyArmor = EnergyArmor;
            this.Type = Type;
            this.Cost = Cost;
        }

        public override void OnAttach(Entity Entity)
        {
            base.OnAttach(Entity);
            if (KineticArmor > 0)
            {
                AttributeFilter Af = new AttributeFilter(this.Name, this.Color, this, 
                    Entity["Armor (Kinetic)"], 
                    value => value + this.KineticArmor);
                Af.Owner = this;
                Entity.Add(Af);
            }
            if (EnergyArmor > 0)
            {
                AttributeFilter Af = new AttributeFilter(this.Name, this.Color, this,
                    Entity["Armor (Energy)"],
                    value => value + this.KineticArmor);
                Af.Owner = this;
                Entity.Add(Af);
            }
        }

        public string type
        {
            get { return this.Type; }
        }
        public int kineticArmor
        {
            get { return this.KineticArmor; }
        }
        public int energyArmor
        {
            get { return this.EnergyArmor; }
        }
        public string creditCost
        {
            get { return this.Cost; }
        }
    }
}